package com.yl.flink.redis;

import com.yl.constant.RedisCmd;
import org.apache.flink.api.java.tuple.Tuple3;

public class RedisSinkMapper implements RedisMapper<Tuple3<String, Integer, Integer>> {

    /**
     * 数据类型
     */
    @Override
    public RedisCmdDesc getCmdDesc() {
        return new RedisCmdDesc(RedisCmd.STTL);
    }

    /**
     * key
     */
    @Override
    public String getKeyFromData(Tuple3<String, Integer, Integer> tuple3) {
        return tuple3.f0;
    }

    /**
     * value
     */
    @Override
    public String getValueFromData(Tuple3<String, Integer, Integer> tuple3) {
        return tuple3.f1.toString();
    }

    /**
     * ttl
     */
    @Override
    public int getTtlFromData(Tuple3<String, Integer, Integer> tuple3) {
        return tuple3.f2;
    }
}
